//
//  STApplicationFormTableView.m
//  赛拓
//
//  Created by 王磊 on 8/13/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STApplicationFormTableView.h"
#import "STApplicationFormHeaderTableView.h"
#import "STApplicationFormBean.h"
@interface STApplicationFormTableView()<STBaseViewDelegate>
@property (nonatomic ,strong) STApplicationFormHeaderTableView *header;
@end
@implementation STApplicationFormTableView

- (void)commitInit {
    [super commitInit];
    
    [self setHeader];
    
    [self setFooter];
}

- (void)setHeader {
    STApplicationFormHeaderTableView *header = [STApplicationFormHeaderTableView instance];
    
    self.header = header;
    
    header.frame = CGRectMake(0, 0, ST_SCREEN_WIDTH, 600 * ST_RATE);
    
    self.tableHeaderView = header;
    
    header.cellType = STCellTypeMaterial;
    
    header.mDelegate = self;
    
    NSArray *data = @[@{
                          @"infoTitle":@"公司名称",
                          @"infoDes":@""
                          },
                      @{
                          @"infoTitle":@"营业执照号码",
                          @"infoDes":@""
                          },
                      @{
                          @"infoTitle":@"联系人姓名",
                          @"infoDes":@""
                          },
                      @{
                          @"infoTitle":@"联系人电话",
                          @"infoDes":@""
                          },
                      @{
                          
                          @"infoTitle":@"详细地址",
                          @"infoDes":@""
                          }];
    NSArray *array = [STApplicationFormBean  mj_objectArrayWithKeyValuesArray:data];
    
    [header updateData: array];
}
- (void)setFooter {
    UIView *view = [UIView new];
    
    UIButton *footer = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [footer setTitle:@"下一步" forState:UIControlStateNormal];
    
    [footer setTitle:@"下一步" forState:UIControlStateHighlighted];
    
    [footer addTarget:self action:@selector(complete) forControlEvents:UIControlEventTouchUpInside];
    
    footer.frame = CGRectMake(0, 0, ST_SCREEN_WIDTH, 40);
    
    view.frame = CGRectMake(0, 0, ST_SCREEN_WIDTH, 65);
    
    [view addSubview:footer];
    
    self.tableFooterView = view;
}

- (void)complete {
    
    [self.mDelegate onItemClick:STItemClickTypeComplete withData:nil forIndexPath:nil];
}
- (void)updateHeader:(id)data forIndexPath:(NSIndexPath *)indexPath {
    
    [self.header updateData:data forIndexPath:indexPath];
    
}
- (void)onItemClick:(STItemClickType)itemType withData:(id)data forIndexPath:(NSIndexPath *)indexPath {
    
    [self.mDelegate onItemClick:itemType withData:data forIndexPath:indexPath];
}
@end
